package com.lz.hotel_java.mapper;

import com.lz.hotel_java.entity.Admin;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AdminMapper {
    @Select("SELECT * FROM Admin WHERE AdminID = #{adminId}")
    Admin selectById(Integer adminId);

    @Select("SELECT * FROM Admin WHERE Username = #{username}")
    Admin selectByUsername(String username);

    @Select("SELECT * FROM Admin")
    List<Admin> selectAll();

    @Insert("INSERT INTO Admin(Username, PasswordHash) VALUES(#{username}, #{passwordHash})")
    @Options(useGeneratedKeys = true, keyProperty = "adminId")
    int insert(Admin admin);

    @Update("UPDATE Admin SET Username = #{username}, PasswordHash = #{passwordHash} WHERE AdminID = #{adminId}")
    int update(Admin admin);

    @Delete("DELETE FROM Admin WHERE AdminID = #{adminId}")
    int deleteById(Integer adminId);
}
